#!/usr/bin/env python

import os

arquivos = \
	[ '500000', '1000000', '2000000' ]

os.system('mkdir ../ExpT4');
for e in range(10):
	print 'Iniciando serie ' + str(e)
	folder = '../ExpT4/e' + str(e)
	os.system('mkdir ' + folder)

	print '\tSequencial '
	os.system('/usr/bin/time -o ' + folder + '/sequencial_t.txt' +\
		' ./projeto-04-seq < ../insensitive.txt'\
		+ ' 1>> ' + folder + '/sequencial_o.txt' \
		+ ' 2>> ' + folder + '/sequencial_e.txt' )

	for i in range(len(arquivos)) :
		print '\tT ' + arquivos[i]

		for j in [2, 4, 6, 8, 10] :
			print '\t\tQty nodes = ' + str(j)
			os.system('echo ' + str(j) + \
				' >> ' + folder + '/mpi_o_t_' + arquivos[i] + '_' + str(j) + '.txt')

			os.system('echo ' + str(j) + \
				' >> ' + folder + '/mpi_e_t_' + arquivos[i] + '_' + str(j) + '.txt')

			os.system('mpirun -np ' + str(j) + ' --hostfile hosts'\
				' projeto-04-mpi ' + \
			 	'/home/grupo15turmaB/insensitive.txt ' + arquivos[i] \
				+ ' 1>> ' + folder + '/mpi_o_t_' + arquivos[i] + '_' + str(j) + '.txt'
				+ ' 2>> ' + folder + '/mpi_e_t_' + arquivos[i] + '_' + str(j) + '.txt')
